<template>
    <div class="check">
        <dialog-cancel-task :order-id="id" v-model="remark" v-on:cancel="cancelTask"></dialog-cancel-task>
    </div>
</template>

<script>
    import DialogCancelTask from '../../components/dialogModel/CancelTask.vue';
    export default {
        name: 'task-detail',
        props: {
            params: {
                type: Object,
                default: () => {
                    return {}
                }
            }
        },
        components: {
            DialogCancelTask
        },
        data() {
            return {
                remark:''
            }
        },
        computed: {
            id: function (value) {
                return this.params.id
            }
        },
        created() {
        },
        methods: {
            cancelTask() {
                let params = {
                  comment: this.remark
                };
                let api;
                if (this.id.split(',').length === 1) {
                    api = 'express/order/' + this.id
                } else {
                    api = 'express/batch_cancel_order?ids=' + this.id
                }
                this.$http.delete(api, {params:params})
                    .then((response) => {
                        this.$message.success('取消成功');
                        this.$emit('closeDialog');
                        this.$store.commit('refreshDialog');
                    })
                    .catch((error) => {
                        if (error.response.data.msg) {
                            this.$message.error(error.response.data.msg);
                        } else {
                            this.$message.error('请求错误：' + error.response.status);
                        }
                    });
            }
        }
    }
</script>

<style scoped>

</style>
